@extends('admin.layout')
@section('title',$title)
@section('content')
	<div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                用户管理
                <small>用户管理编辑页面</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 用户管理</a></li>
                <li class="active">用户编辑</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">用户编辑</h3>
                        </div><!-- /.box-header -->
                        <!-- form start -->
                        @if(session('error'))
                            {{session('error')}}
                        @endif
                        @if (count($errors) > 0)
                            <div class="alert alert-danger">
                                <ul>
                                    @foreach ($errors->all() as $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ul>
                            </div>
                        @endif
                        
                        <form role="form" action="/admin/user/update" method="post" enctype="multipart/form-data">
                            {{ csrf_field() }}
                            <input type="hidden" value="{{$data -> id}}" name="id">
                            <input type="hidden" value="{{$data_b -> pic}}" name="oldpic">
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="exampleInputEmail1">用户名</label>
                                    <input type="text" name="username" value="{{$data -> username}}" class="form-control" id="exampleInputEmail1"
                                           placeholder="请输入6-18位的用户名">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputEmail1">性别</label>
                                    <select class="form-control select2" style="width: 20%;" name="sex">
                                        <option
                                        @if($data_b -> sex == 1)
                                        selected="selected"
                                        @endif
                                        >男</option>
                                        <option
                                        @if($data_b -> sex == 2)
                                        selected="selected"
                                        @endif
                                        >女</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputEmail1">年龄</label>
                                    <input type="text" name="age" value="{{$data_b -> age}}" class="form-control" id="exampleInputEmail1"
                                           placeholder="请输入您真实的年龄">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword1">邮箱</label>
                                    <input type="email" value="{{$data_b -> email}}" name="email" class="form-control" id="exampleInputPassword1"
                                           placeholder="请输入正确的邮箱">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword1">手机</label>
                                    <input type="text" name="phone" value="{{$data -> phone}}" class="form-control" id="exampleInputPassword1"
                                           placeholder="请输入11位手机号">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword1">个人头像</label>
                                    <img src="{{$data_b -> pic}}" width="200" height="200">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputFile">个人头像</label>
                                    <input type="file" name="pic" id="exampleInputFile">
                                    <p class="help-block">请输入漂亮的图片</p>
                                </div>
                                <div class="info">
                                    <label for="exampleInputEmail1">地址</label>
                                    <div>
                                        <select id="s_province" name="s_province"></select>&nbsp;&nbsp;
                                        <select id="s_city" name="s_city" ></select>&nbsp;&nbsp;
                                        <select id="s_county" name="s_county"></select>
                                        <script type="text/javascript" src="/common/js/area.js"></script>
                                        <script type="text/javascript">_init_area();</script>
                                         街道&nbsp;&nbsp;<input type="text" name="jiedao" value="{{$arr[3]}}" placeholder="请输入详细的街道">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputEmail1">状态</label>
                                    <select class="form-control select2" style="width: 20%;" name="status">
                                        <option
                                        @if($data -> status == 1)
                                        selected="selected"
                                        @endif
                                        >启用</option>
                                        <option
                                        @if($data -> status == 2)
                                        selected="selected"
                                        @endif
                                        >禁用</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputEmail1">权限</label>
                                    <select class="form-control select2" style="width: 20%;" name="quanxian">
                                        <option
                                        @if($data -> quanxian == 1)
                                        selected="selected"
                                        @endif
                                        >普通用户</option>
                                        <option
                                        @if($data -> quanxian == 2)
                                        selected="selected"
                                        @endif
                                        >管理员</option>
                                    </select>
                                </div>
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">保存</button>
                                <button type="submitreset" class="btn btn-danger">重置</button>
                            </div>
                        </form>
                    </div><!-- /.box -->

                   
                </div><!--/.col (left) -->

            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
    <script type="text/javascript">
        $('#s_province').append('<option selected>{{$arr[0]}}</option>');
        $('#s_city').append('<option selected>{{$arr[1]}}</option>');
        $('#s_county').append('<option selected>{{$arr[2]}}</option>');
        var Gid  = document.getElementById ;
        var showArea = function(){
            Gid('show').innerHTML = "<h3>" + Gid('s_province').value + " - " + 
                                    Gid('s_city').value + " - " + 
                                    Gid('s_county').value + "</h3>"
        }
        Gid('s_county').setAttribute('onchange','showArea()');
    </script>
@endsection
